package com.yanqu.road.server.timer;

import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class PlayerDataSaveTask extends GeneralTask {

	private Logger logger = LogManager.getLogger(this.getClass().getName());

	private  int saveIndex;

	private boolean saving = false;

	public PlayerDataSaveTask(int saveIndex){
		  this.saveIndex = saveIndex;
	}

	@Override
	public void doRun() {
		if(!saving){
			saving = true;
			try {
				GamePlayerMgr.timeSave(saveIndex);
			}catch (Exception e){
				logger.error("save user data error:", e);
			}finally {
				saving = false;
			}
		}
	}
}
